<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title></title>
  </head>
  <body>
    <pre>
        注册或获取全局过滤器。
      </pre
    >
    <div class="box">
      <form action="">
        <label for="ting">
          用户名 ：
          <input type="text" v-model="datas" />
        </label>
        <button>{{datas | up}}</button>
      </form>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
      //全局方法
      //   Vue.filter('up', function (el) {
      //     return el.charAt(0).toUpperCase() + el.slice(1)
      //   })
      new Vue({
        el: '.box',
        data: { datas: '' },
        methods: {},
        computed: {},
        watch: {},
        // 局部方法
        filters: {
          up: function (el) {
            return el.charAt(0).toUpperCase() + el.slice(1)
          },
        },
      })
    </script>
  </body>
</html>
